from core.tao import HttpHeader
from apitest import AssertConst
'''自动化接口测试核心模块'''


'''断言处理类
1. 全静态方法
'''
class Assert:
    @staticmethod
    def be_empty(data, oData = None):
        pass

    @staticmethod
    def has_key(data, key):
        pass

    @staticmethod
    def have_keys(data, keys):
        pass

    @staticmethod
    def be_eq(data, val):
        pass

    @staticmethod
    def be_error(data, oData = None):
        pass

    @staticmethod
    def be_right(data, oData = None):
        pass

    @staticmethod
    def be_download(data, oData = None):
        pass

    @staticmethod
    def be_excel(data, oData = None):
        pass


#断言对照关系
assertMap = {
    AssertConst.SHOULD_BE_EMPTY: Assert.BeEmpty,
    AssertConst.SHOULD_BE_ERROR: Assert.BeError,
    AssertConst.SHOULD_BE_RIGHT: Assert.BeRight,
    AssertConst.SHOULD_BE_DOWNLOAD: Assert.BeDownload,
    AssertConst.SHOULD_BE_EQ: Assert.BeEq
}


#检查
def Check(fromData, assertWord=AssertConst.SHOULD_BE_RIGHT, checkData=None):
    try:
        assertMap[assertWord](fromData, checkData)
    except Exception as e:
        raise '判断语句出错'



# 实例
def describe(desc: str, fn):
    fn()

# 一个用例
def it(desc: str, fn):
    try:
        fn()
        return True
    except():
        return False

